package com.fagejiang.memory;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * 你还没有写描述儿~
 *
 * @author <发哥讲Java-694204477@qq.com>
 * @version 1.0
 * @date 2021-06-16 21:35
 */
@Service
@Slf4j
public class BizService {

    public void initData() {
        for (int i = 0; i < 10; i++) {
            DataPool.addCun("key" + i, "val-" + i);
        }
        log.info(" 数据初始化完成...{} ", DataPool.CUN_MAP);
    }


    @SneakyThrows
    public void executeTask1() {
        log.info(" executeTask1 任务执行开始...{} ", DataPool.CUN_MAP.size());
        AtomicBoolean flag = new AtomicBoolean(false);
        do {
            for (int i = 0; i < 10; i++) {
                TimeUnit.SECONDS.sleep(2);
                log.info(" 获取{}的值为:{} ", i, DataPool.getCunJWHNameByDm("key" + i));
            }
        } while (flag.get());
        log.info(" executeTask1 任务执行完成...{} ", DataPool.CUN_MAP.size());

    }
}
